package model;

import model.interfaces.DicePair;
import model.interfaces.Player;

/**
 * Created by heyuxun on 2018/4/4.
 */
public class SimplePlayer implements Player {
    String playerId=null;
    String playerName=null;
    int points=0;//initial points is 0
    int bet=0;//initializing the bet
    DicePair diceP = new DicePairImpl(0,0,6);
    int result=0;

    public SimplePlayer(String playerId, String playerName, int initialPoints) {//constructor
        this.playerId= playerId;
        this.playerName= playerName;
        this.points= initialPoints;
    }

    @Override
    public String getPlayerName() {//To get player name
        return this.playerName;
    }

    @Override
    public void setPlayerName(String playerName) {// To set player name
        this.playerName= playerName;
    }

    @Override
    public int getPoints() {
        return this.points;
    }// To get current points

    @Override
    public void setPoints(int points) {// To set a new points
        this.points= points;
    }

    @Override
    public String getPlayerId() {
        return this.playerId;
    } // To get player ID

    @Override
    public boolean placeBet(int bet) {// To judge a verified Bet
        if(bet<=0)
            return false;
        else {
            this.bet = bet;
            return true;
        }
    }

    @Override
    public int getBet() {
        return this.bet;
    }

    @Override
    public int getRollResult() {// To get a dice value for resulting

        return result;
    }

    @Override
    public void setRollResult(DicePair rollResult) {// generate a random dice and setting on
        rollResult.getDice1();
        rollResult.getDice2();
        result= rollResult.getNumFaces();
    }

    @Override
    public String toString() {
        return String.format("%s",playerName);
    }
}
